﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArduinoAnalyzer.SemanticAnalysis
{
    public class Code
    {
        public Code()
            : this(string.Empty)
        {

        }

        public Code(string code)
        {
            _sb = new StringBuilder();
            this.AppendLine(code);
        }

        private StringBuilder _sb;

        public void AppendLine(string line)
        {
            if (!string.IsNullOrEmpty(line))
                _sb.AppendLine(line);
        }

        public void Append(Code code)
        {
            if (!string.IsNullOrEmpty(code.ToString()))
                _sb.Append(code.ToString());
        }

        public override string ToString()
        {
            return _sb.ToString();
        }

        public static implicit operator Code(string line)
        {
            return new Code(line);
        }
    }
}
